{extend name="layout" /}
{block name="content"}
<div class="row">
  <div class="col-xs-6" style="text-align: right">
    <form id="searchForm">
      <div class="seardiv" style="width: 20%;float: left;">
        <select name="kind" class="form-control input-sm">
          <option value="">请选择线索分类</option>
          {volist name=":config('CLIENT_KIND')" id="v"}
          <option value="{$key}">{$v}</option>
          {/volist}
        </select>
      </div>
      <div class="seardiv" style="width: 20%;float: left;">
        <select name="status" class="form-control input-sm">
          <option value="">请选择线索状态</option>
          {volist name=":config('CLIENT_STATUS')" id="v"}
          <option value="{$key}">{$v}</option>
          {/volist}
        </select>
      </div>
      <div class="seardiv" style="width: 20%;float: left;">
        <select name="dealerid" class="form-control input-sm">
          <option value="">请选择经销商</option>
          {volist name="$deallist" id="v"}
          <option value="{$key}">{$v}</option>
          {/volist}
        </select>
      </div>
      <div class="input-group input-group-sm demoTable">
        <input type="text" class="form-control input-sm" name="keywords" id="demoReload" autocomplete="off"
          placeholder="请输入线索手机号、线索姓名">
        <span class="input-group-btn">
          <button type="button" class="btn btn-info btn-flat layui-btn" data-type="reload">搜 索</button>
        </span>
      </div>
    </form>
  </div>
  <div class="col-xs-6" id="toolbar" style="text-align: right">
    <button type="button" class="btn btn-danger btn-sm btnAction" data-type="delAll" confirm="确定要删除吗？" checkItem="1:0"
      ajaxUrl="{:url('data_delete',array('model'=>$model))}"><i class="fa fa-remove"></i> 批量删除</button>
    <button type="button" class="btn btn-info btn-sm export" title="线索列表"><i class="fa fa-edit"></i> 数据导出</button>
  </div>
</div>
<table class="layui-table"
  lay-data="{height: 'full-75', cellMinWidth: 80, page: true, id:'lists',limit:30, url:'{:url('data_show_where',['whereData'=>$whereData,'order'=>'desc'])}'}"
  lay-filter="lists">
  <thead>
    <tr class="layui-colla-content">
      <th lay-data="{type:'checkbox'}">ID</th>
      <th lay-data="{field:'id', sort: true}">ID</th>
      <th lay-data="{field:'name'}">姓名</th>
      <th lay-data="{field:'kindname'}">线索类别</th>
      <th lay-data="{field:'product'}">意向产品</th>
      <th lay-data="{field:'price'}">线索金额</th>
      <!-- <th lay-data="{field:'city'}">所在城市</th> -->
      <th lay-data="{field:'phone'}">手机号</th>
      <!-- <th lay-data="{field:'qq'}">社交账号</th> -->
      <th lay-data="{field:'getdate'}">获取时间</th>
      <th lay-data="{field:'home'}">住址</th>
      <!-- <th lay-data="{field:'realname'}">所有者</th> -->
      <!-- <th lay-data="{field:'directorname'}">销售总监</th> -->
      <th lay-data="{field:'brokerid'}">所属经纪人</th>
      <th lay-data="{field:'skilledname'}">用户级别</th>
      <th lay-data="{field:'statusname'}">状态</th>
      <th lay-data="{field:'dealer'}">经销商</th>
      <!-- <th lay-data="{field:'typename'}">客户类型</th> -->
      <th lay-data="{field:'adddate'}">添加时间</th>
      <th lay-data="{fixed: 'right', width:120, align:'center', toolbar: '#barDemo'}">操作</th>
  </thead>
</table>
<script type="text/html" id="barDemo">
  <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
  <a class="layui-btn layui-btn-xs" lay-event="client_deliver">转交</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
{/block}
{block name="script"}
<script type="text/javascript">
  layui.use('table', function () {
    var table = layui.table;
    var $ = layui.$, active = {
      reload: function () {
        var demoReload = $('#demoReload');
        //执行重载
        table.reload('lists', {
          page: {
            curr: 1 //重新从第 1 页开始
          }
          , where: $('#searchForm').serializeObject()
        });
      }
    };
    $('.demoTable .layui-btn').on('click', function () {
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
</script>
<script type="text/javascript">
  function client_deliver(data) {
    var layindex = layer.open({
      type: 2,
      area: ['800px', '600px'],
      fixed: false, //不固定
      maxmin: true,
      content: APP_URL + "/admin/client/client_deliver?id=" + data.id,
      title: '发货',
      btn: ['确定', '取消'],
      shade: [0.8, '#000000'],
      yes: function (index, layero) {
        //parent.$('#parentIframe').text('我被改变了');
        var iframeWin = window[layero.find('iframe')[0]['name']];
        formobj = iframeWin.$("form");
        ajaxUrl = formobj.attr("action");
        if (ajaxUrl == undefined || ajaxUrl == '') {
          ajaxUrl = defaultSaveUrl;
        }
        datajson = formobj.serialize();
        searchMap.postData = datajson;
        console.log(datajson);
        $.post(ajaxUrl, searchMap, function (datajson) {
          var serializeObj = {};
          if (datajson.status == 1) {
            $(formobj.serializeArray()).each(function () {
              serializeObj[this.name] = this.value;
            });
            layer.msg("操作成功", function () {
              layer.closeAll();
            });
            setTimeout(function () {
              location.reload();
            }, 300);
          }
          else {
            layer.msg(datajson.msg);
            return false;
          }
        }, 'json');
      }
    });
  }
</script>
{/block}